<%@page import="java.util.List"%>
<%@page import="database.*"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="/Project1/layui-v2.6.13/layui/css/layui.css"/>
		<style>
			#limitPage button{
				margin: 0;
			}
		</style>
		<script type="text/javascript" src="/Project1/layui-v2.6.13/layui/layui.js"></script>
		<script type="text/javascript" src="/Project1/js/jquery-1.9.1.min.js"></script>
	</head>
	<body>

		<div style="padding: 20px;">
			<div>
				<form class="layui-form" action="<%=request.getContextPath()%>/c" method="post">
				<input type="hidden" name="method" value="select">
				<div class="layui-inline">
					<select name="cname" id="college" lay-filter="s1">
						<option value="" selected>学院</option>
						<c:forEach items="${colist}" var="obj">
							<option value="${obj.id }" <c:if test="${obj.id eq cn}">selected</c:if>>${obj.name}</option>
						</c:forEach>
					</select>
				</div>
				<div class="layui-inline">
					<select name="mname" id="major" lay-filter="s2">
						<option value="" selected>专业</option>
						<c:forEach items="${ma}" var="obj">
							<option value="${obj.id }" <c:if test="${obj.id eq mn}">selected</c:if>>${obj.name}</option>
						</c:forEach>
					</select>
				</div>
				<input type="submit" class="layui-btn" value="查询">
				<button type="button" class="layui-btn" onclick="cz()">重置</button>
			</form>
			</div>
			<div style="margin-top:20px;">
				<button class="layui-btn" onclick="openLayer2()">添加</button>
				<button class="layui-btn">导出表格</button>
				<table class="layui-table table">
					
					<thead>
						<tr>
						
							<th>学院</th>
							<th>专业</th>
							<th>操作</th>
						</tr> 
					</thead>
					<tbody >
						
						<c:forEach items="${mix }" var="m">
						
							<tr>
								<input type="hidden" value="${m.id }">
								<td>${m.cname }</td>
								<td>${m.mname }</td>
								<td><button class="layui-btn" onclick="openLayer(${m.id})">更新</button></td>
							</tr>
						
						</c:forEach>
						
					</tbody>
				</table>
			</div>
			<div id="limitPage" align="center">
				<button class="layui-btn layui-btn-sm layui-btn-primary layui-border-green" onclick="jump(1,${pagenum})">首页</button>
				<button class="layui-btn layui-btn-sm" onclick="jump(${page-1},${pagenum})">上一页</button>
				<span class="layui-font-16">${page }/${pagenum }页</span>
				<button class="layui-btn layui-btn-sm" onclick="jump(${page+1},${pagenum})">下一页</button>
				<button class="layui-btn layui-btn-sm layui-btn-primary layui-border-green" onclick="jump(${pagenum},${pagenum})">尾页</button>
			</div>
		</div>
	</body>
	<script>
		function cz(){
			window.location.href = "c?method=select";
		} 
		function jump(page,pagenum){
			if(page<1) page=1;
			if(page>pagenum) page=pagenum;
			var form = $("form").serialize();
			window.location.href = "c?method=topage&page="+page+"&pagenum="+pagenum+"&"+form;
		}	
	
		layui.use("layer", function(){
			var layer = layui.layer;
		});
		
		function openLayer(id){
			layer.open({
			  type: 2, 
			  area: ['650px', '500px'],
			  content: 'page/colup.jsp?id='+id,
			  end: function(){
				  location.reload();
			  }
			});
		}
		function openLayer2(){
			layer.open({
			  type: 2, 
			  area: ['650px', '500px'],
			  content: 'page/colin.jsp',
			  end: function(){
				  location.reload();
			  }
			});
		}
	</script>
	
	
</html>





















